/*! \file HXTalk.h
    \brief Speech text/tag parsing.

	Head X | Flinders University | Martin Luerssen & Trent Lewis | 2009+
*/

#pragma once

#include "HXPlayer.h" 
#include "HXAlive.h"
#include "HXSpeech.h"

#define MAX_WORDINDEX 10000000

typedef unsigned __int32 HXParseTagType;
const HXParseTagType HXPTT_NONE = 0x00000000;
const HXParseTagType HXPTT_EMOTE = 0x00000001;
const HXParseTagType HXPTT_BREAK = 0x00000002;
const HXParseTagType HXPTT_FG = 0x00000004;
const HXParseTagType HXPTT_SUBTITLE = 0x00000008;
const HXParseTagType HXPTT_SYSTEM = 0x00000010;
const HXParseTagType HXPTT_REINSERT = 0x00000020;

//-----------------------------------------------------------------------------

//! Text processor.
class HXTalk
{
public:
	HXTalk(HXAliveProcessor* pAlive);
	void SetSpeechClient(HXSpeech* speechTTS, bool* pbThreadExit);
	void Speak(const wchar_t* text);
	void SpeakDirect(const wchar_t* text);

	bool& BreakOnStop() { return m_bBreakOnStop; }
	void ClearExpressionToggles(bool trigRevert, float delay = 0.0f, unsigned int trigIndex = 0);
	HXParseTagType Parse(wchar_t* filtered);
	HXParseTagType ParseTag(const wchar_t* text, bool staticUse = false);

protected:
	HXSpeech* m_pSpeechTTS;
	HXAliveProcessor* m_pAlive;
	bool*	m_pbThreadExit;
	wchar_t m_replace[MAX_TEXT_LENGTH];
	wchar_t m_response[MAX_TEXT_LENGTH];
	int		m_responsePosition;
	double	m_responseDelay;
	long	m_pauseStartTime;
	bool	m_bBreakOnStop;
	size_t	m_wordIndex;

	bool	m_bReplaceSubtitle;
	wstring m_subtitleString; // only used if m_bReplaceSubtitle is true
};

//=============================================================================

extern HXTalk g_talk;